


#Compare means of the four items by treatment
#Plot the Means
library(Rmisc)
library(DescTools)
library(cowplot)
##make a better treatment indicator

study1$treatment2<-as.factor(study1$treatment)
levels_temp=c("Control", "Boy", "Girl", "Before", "After")




##Plot the means by condition
ind_mean <- summarySE(study1, measurevar="Independence", groupvars="treatment2",
                      na.rm=TRUE, conf.interval=.95)
ind_mean$test<-c("Control", "Boy", "Girl")

##recode to zero one
ind_mean$Ind2<-ind_mean$Independence-1

plot_elder<-ggplot(ind_mean, aes(x=factor(test, level =c('Control','Boy', 'Girl')), y=Ind2, group=1)) +
  geom_line() +
  geom_errorbar(width=.1, aes(ymin=Ind2-ci, ymax=Ind2+ci), colour="red", data=ind_mean) +
  geom_point(shape=21, size=1, fill="white")+
  xlab("Treatment")+
  ylab("Proportion choosing \n'Respect for Elders'")+
  ylim(0,1)+ theme_bw()
plot_elder
Independence.aov<-aov(Independence~as.factor(treatment2), data=study1)
summary(Independence.aov)
TukeyHSD(Independence.aov)







obed_mean <- summarySE(study1, measurevar="Obedience", groupvars="treatment2",
                       na.rm=TRUE, conf.interval=.95)

obed_mean
##recode to zero one
obed_mean$obed2<-2-obed_mean$Obedience
obed_mean$test<-c("Control", "Boy", "Girl")

plot_obed<-ggplot(obed_mean, aes(x=factor(test, level =c('Control','Boy', 'Girl', 'After', 'Before')), y=obed2, group=1)) +
  geom_line() +
  geom_errorbar(width=.1, aes(ymin=obed2-ci, ymax=obed2+ci), colour="red",data=obed_mean) +
  geom_point(shape=21, size=1, fill="white") +
  xlab("Treatment")+
  ylab("Proportion choosing \n'Obedience'")+
  ylim(0,1)+ theme_bw()

plot_obed

Obedience.aov<-aov(Obedience~as.factor(treatment), data=study1)
summary(Obedience.aov)
TukeyHSD(Obedience.aov)



cur_mean <- summarySE(study1, measurevar="Curiosity", groupvars="treatment2",
                      na.rm=TRUE, conf.interval=.95)

cur_mean

##recode to zero one
cur_mean$cur2<-cur_mean$Curiosity-1
cur_mean$test<-c("Control", "Boy", "Girl")

plot_cur<-ggplot(cur_mean, aes(x=factor(test, level =c('Control','Boy', 'Girl')), y=cur2, group=1)) +
  geom_line() +
  geom_errorbar(width=.1, aes(ymin=cur2-ci, ymax=cur2+ci), colour="red", data=cur_mean) +
  geom_point(shape=21, size=1, fill="white") +
  xlab("Treatment")+
  ylab("Proportion choosing \n'Good Manners'")+ylim(0,1)+ theme_bw()
plot_cur

Curiosity.aov<-aov(Curiosity~as.factor(treatment), data=study1)
summary(Curiosity.aov)
TukeyHSD(Curiosity.aov)


con_mean <- summarySE(study1, measurevar="Considerate", groupvars="treatment2",
                      na.rm=TRUE, conf.interval=.95)

con_mean

##recode to zero one
con_mean$con2<-con_mean$Considerate-1
con_mean$test<-c("Control", "Boy", "Girl")

plot_con<-ggplot(con_mean, aes(x=factor(test, level =c('Control','Boy', 'Girl')), y=con2, group=1)) +
  geom_line() +
  geom_errorbar(width=.1, aes(ymin=con2-ci, ymax=con2+ci), colour="red", data=con_mean) +
  geom_point(shape=21, size=1, fill="white") +
  xlab("Treatment")+
  ylab("Proportion choosing \n'Well-Behaved'")+ylim(0,1)+ theme_bw()

plot_con
Considerate.aov<-aov(Considerate~as.factor(treatment), data=study1)
summary(Considerate.aov)
TukeyHSD(Considerate.aov)

pdf(file="Figure1.pdf")
plot_grid(plot_elder, plot_obed, plot_cur, plot_con)
dev.off()

##recode to zero one
ind_mean$Ind2<-ind_mean$Independence-1


study1$auth<-(study1$Independence-1+(2-study1$Obedience)+
                 study1$Curiosity-1+study1$Considerate-1)
study1$treatment2

Author_mean <- summarySE(study1, measurevar="auth", groupvars="treatment2",
                         na.rm=TRUE, conf.interval=.95)

Author_mean$Author<-Author_mean$auth
Author_mean$test<-c("Control", "Boy", "Girl")


plot_Author<-ggplot(Author_mean, aes(x=factor(test, level =c('Control','Boy', 'Girl')), 
                                     y=Author, group=1)) +
  geom_line() +
  geom_errorbar(width=.1, aes(ymin=Author-ci, 
                              ymax=Author+ci), colour="red", 
                data=Author_mean) +
  geom_point(shape=21, size=1, fill="white") +
  xlab("Treatment")+
  ylab("Authoritarianism measure")+ylim(0,4)+ theme_bw()


pdf(file="Figure4.pdf")
plot_Author
dev.off()
Author.aov<-aov(auth~as.factor(treatment), data=study1)
summary(Author.aov)
TukeyHSD(Author.aov)

